#ifndef __cTypes_h__
#define __cTypes_h__

// cTypes.h (/Common) ---------------------------------
// Header files contains main data types and definitions
// for video compression project
//
// (C) 2000, Streambox Inc.
// All Rights Reserved. 
//
// Written by Alex Telitsine
// 
// history:
// created July 17, 2000 alex@streambox.com
//
//
//

//#include "../winapp/stdafx.h"
//-------------------------- comatable with WINDOWS.H -----------------
//-------- if used with windows, windows.h should be included before cTypes.h--





#ifdef WIN32
	#include <process.h>
#endif

#ifdef _mapca_
	#include <mm.h>
	#ifdef _mapds_				// MAP data streamer support
		#include <eti/ds.h>
	#endif
#endif
#ifndef _WINDEF_
	#ifndef _mapds_

		#ifndef VOID
		 typedef void VOID;
		#endif
  
		#ifndef BYTE
		 typedef unsigned char BYTE;
		#endif

		#ifndef CHAR
		 typedef unsigned char CHAR;
		#endif

		#ifndef UCHAR
		 typedef unsigned char UCHAR;
		#endif
 
		#ifndef DWORD
		 typedef unsigned int DWORD;
		#endif
 
		#ifndef ULONG
		 typedef unsigned long ULONG;
		#endif
 
		#ifndef BOOL
		 typedef int BOOL;
		#endif
 
		#endif //_WINDEF_ ------- windows already has the types defined

		#ifndef CHANNEL
		 typedef BYTE* CHANNEL;
		#endif

		#ifndef FAILURE
		 #define FAILURE -1
		#endif

		#ifndef TRUE
		 #define TRUE 1
		#endif
 
		#ifndef FALSE
		 #define FALSE 0
		#endif
	#else
	#endif


#ifndef WORD
#ifndef _WINDEF_
 typedef unsigned short WORD;
#endif
#endif


#ifndef ABS               

#ifdef _TI_
	#define ABS(i) _abs(i)
#else
	#define ABS(i) ((i) < 0 ? -(i) : (i))
#endif
#endif

//debug
void PrintCRC(char* str,void* ptr,int size);

#ifdef _TI_                                          
#define EXTRACT_BIT(a,sl,sr) _extu(a,sl,sr)     // "a" should beunsigned
#else
#define EXTRACT_BIT(a,sl,sr) (((a)<<(sl))>>(sr))     // "a" should beunsigned
#endif

	//------------------------- TI defenitions ---------------------------------------
	#ifdef _TI_              
		#define RESTRICT restrict
		#define INLINE inline
		#define unroll_amount(a) 
		#define if_prob(a)
	#else
	//------------------------- MMX defenitions ---------------------------------------
	#ifdef _MMX_
		#define RESTRICT 
		#define INLINE _inline
		#define unroll_amount(a) 
		#define if_prob(a)	
	#else
	//------------------------- MAP-CA defenitions ---------------------------------------
	#ifdef _mapca_
			#define RESTRICT restrict

			#ifdef _mapds_				// <---------- MAP data streamer support
				#define INLINE inline
				#define print kprintf
			#else						// <-----------for MAP on Intel emulation, no Datastreamer(DMA)
				#define print printf
				#define INLINE _inline	
				#define hmpv_prefetch(a) 
				#define unroll_amount(a) 
				#define if_prob(a)
				#define hmpv_rs_u32_td	hmpv_rs_pu32_td
				#define hmpv_ls_32	hmpv_ls_pu32
				#define hmpv_rs_u32_td	hmpv_rs_pu32_td
				#define hmpv_bor_32(a,b)  (n32)hmpv_bor_64(a,b)
			#endif
	#else	  
	//------------------------- Generic C defenitions ---------------------------------------
			#define RESTRICT 
			#define INLINE 
			#define print printf
			#define INLINE 	
			#define unroll_amount(a) 
			#define if_prob(a)	
	#endif
	#endif
	#endif

// enable/disable debug print
#define ENABLE_DEBUG_PRINT 0


#define dprint  if (ENABLE_DEBUG_PRINT) printf
#define dprintf if (ENABLE_DEBUG_PRINT) printf

/*
#ifdef ENABLE_DEBUG_PRINT
#	define dprintf printf
#else 
#	define dprintf
#endif

#ifdef ENABLE_DEBUG_PRINT
#	define dprint printf
#else 
#	define dprint
#endif
*/

//#define CLIP0(x) ((x)<0? 0:(x)>255? 255:(x))	
//#define CLIP(x) CLIP_BYTE[(int)(x)+512]
//extern  BYTE CLIP_BYTE[];
	
#define CLIP(x)  CLIP_BYTE [(int)(x)+1024]
#define CLIPN(x) CLIP_BYTEN[(int)(x)+1024]
extern  BYTE CLIP_BYTE[];
extern  BYTE CLIP_BYTEN[];
#define USE_QUANT_AC2

#endif
